//
// Created by Administrator on 2024/8/2.
//

#ifndef INFLECTION_POINT_H
#define INFLECTION_POINT_H

#include "../interfaces/base.h"
#include "../util/macros.h"

#include "../msgpack/MessagePackWriter.h"
#include "../msgpack/messagepack_reader.h"

namespace protocol {
    class InflectionPoint : public Sizeable, public Serializable {
        uint32_t pointId{};
        uint32_t pathId{};
        uint32_t pointLat{};
        uint32_t pointLng{};
        uint8_t pathWidth{};
        uint8_t pathProperty{};
        uint16_t exceedThreshold{};
        uint16_t lackThreshold{};
        uint16_t maxSpeed{};
        uint8_t overSpeedTime{};
        uint16_t maxSpeedNight{};

        IMPLEMENT_SIZEABLE(pointId, pathId, pointLat, pointLng, pathWidth, pathProperty, exceedThreshold,
            lackThreshold, maxSpeed, overSpeedTime, maxSpeedNight)
    public:
        InflectionPoint() = default;

        InflectionPoint(const uint32_t point_id, const uint32_t path_id, const uint32_t point_lat,
            const uint32_t point_lng, const uint8_t path_width, const uint8_t path_property,
            const uint16_t exceed_threshold, const uint16_t lack_threshold, const uint16_t max_speed,
            const uint8_t over_speed_time, const uint16_t max_speed_night)
            : pointId(point_id),
              pathId(path_id),
              pointLat(point_lat),
              pointLng(point_lng),
              pathWidth(path_width),
              pathProperty(path_property),
              exceedThreshold(exceed_threshold),
              lackThreshold(lack_threshold),
              maxSpeed(max_speed),
              overSpeedTime(over_speed_time),
              maxSpeedNight(max_speed_night) {
        }

        InflectionPoint(const InflectionPoint &other) = default;

        InflectionPoint & operator=(const InflectionPoint &other) = default;

        ~InflectionPoint() override = default;

        void serialize(MessagePackWriter &writer) override {
            JTT809_PASTE(writer.writeUint, ;, pointId, pathId, pointLat, pointLng, pathWidth, pathProperty, exceedThreshold,
            lackThreshold, maxSpeed, overSpeedTime, maxSpeedNight);
        }

        void deserialize(MessagePackReader &reader) override {
            JTT809_PASTE(reader.readUint, ;, pointId, pathId, pointLat, pointLng, pathWidth, pathProperty, exceedThreshold,
            lackThreshold, maxSpeed, overSpeedTime, maxSpeedNight);
        }
    };
}

#endif //INFLECTION_POINT_H
